<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateVassetisTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::dropIfExists('vassetis');
        Schema::create('vassetis', function (Blueprint $table) {
            $table->increments('id');
            $table->string('vasseti_no', 100)->index();
            $table->string('name', 100);
            $table->string('title', 100)->nullable();
            $table->string('subtitle', 100)->nullable();
            $table->decimal('score', 10, 3)->nullable();
            $table->string('season', 100)->nullable();
            $table->integer('episode')->nullable();
            $table->integer('vcat_id')->unsigned()->index();
            $table->integer('vyear_id')->unsigned()->index();
            $table->integer('varea_id')->unsigned()->index();
            $table->integer('vlang_id')->unsigned()->index();
            $table->integer('resolution_id')->unsigned();
            $table->integer('vifile_titbit_id')->unsigned()->nullable();
            $table->integer('vifile_trailer_id')->unsigned()->nullable();
            $table->string('short_desc', 100);
            $table->text('long_desc')->nullable();
            // $table->integer('sp_id')->unsigned()->nullable();
            // $table->integer('cp_id')->unsigned()->nullable();
            // $table->integer('director_id')->unsigned()->nullable();
            // $table->integer('actor_id')->unsigned()->nullable();
            $table->timestamps();
            $table->softDeletes();
            $table->foreign('vcat_id')->references('id')->on('vcats')->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('vyear_id')->references('id')->on('vyears')->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('varea_id')->references('id')->on('vareas')->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('vlang_id')->references('id')->on('vlangs')->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('resolution_id')->references('id')->on('resolutions')->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('vifile_titbit_id')->references('id')->on('vifiles')->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('vifile_trailer_id')->references('id')->on('vifiles')->onUpdate('cascade')->onDelete('cascade');
            // $table->foreign('sp_id')->references('id')->on('sps')->onUpdate('cascade')->onDelete('cascade');
            // $table->foreign('cp_id')->references('id')->on('cps')->onUpdate('cascade')->onDelete('cascade');
            // $table->foreign('director_id')->references('id')->on('directors')->onUpdate('cascade')->onDelete('cascade');
            // $table->foreign('actor_id')->references('id')->on('actors')->onUpdate('cascade')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('vassetis');
    }
}
